package com.cms.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.cms.entity.User;
import com.cms.service.UserService;

/**
*@author:gang
*@version:
**/
@Controller

public class UserAction {
	@Resource
	UserService userService;
	
	@RequestMapping(value="/newregister",method=RequestMethod.POST)
	public ModelAndView register(HttpServletRequest request,HttpServletResponse response, @RequestParam("name")String name,
			@RequestParam("password")String password,@RequestParam("email")String email,@RequestParam("country")String country){
		User user = userService.addUser(name, password, email, country);
		ModelAndView modelAndView = new ModelAndView();
		System.err.println(user.getUserName()+"register success");
		
		modelAndView.setViewName("login");
		return modelAndView;
	}
}
